package com.demo.principle.principleOfOpeningAndClosing;

public class Ocp1 {
    public static void main(String[] args) {
        Editor editor = new Editor();
        editor.drewSharp(new Circle());
        editor.drewSharp(new Rectangle());
        editor.drewSharp(new Triangle());
    }
}

class Sharp {
    int type;
}

class Circle extends Sharp {
    Circle() {
        super.type = 1;
    }
}

class Rectangle extends Sharp {
    Rectangle() {
        super.type = 2;
    }
}

class Triangle extends Sharp {
    Triangle() {
        super.type = 3;
    }
}

class Editor {
    public void drewSharp(Sharp sharp) {
        if (sharp.type == 1) {
            System.out.println("圆形");
        }
        if (sharp.type == 2) {
            System.out.println("矩形");
        }
        if (sharp.type == 3) {
            System.out.println("三角形");
        }
    }
}